﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using KPIS.GERP.GIMS.MODEL;
using KPIS.GERP.GIMS.DAL;

namespace KPIS.GERP.GIMS.BLL
{
    public class EssMessageSendBLL
    {
        private static readonly EssMessageSendDAL dal = new EssMessageSendDAL();

        public DataTable GetCurrentApprover(string emp_seq, string process, int step_no)
        {
            Nullable<int> nemp_seq = string.IsNullOrEmpty(emp_seq) ? (int?)null : Int32.Parse(emp_seq);
            return dal.GetCurrentApprover(nemp_seq, process, step_no);
        }

        public string GetNextStepNo(string approve_path_seq)
        {
            Nullable<int> napprove_path_seq = string.IsNullOrEmpty(approve_path_seq) ? (int?)null : Int32.Parse(approve_path_seq);
            return dal.GetNextStepNo(napprove_path_seq);
        }

        public EssMessageSendInfo GetInfo(Nullable<int> Sequence)
        {
            int nSeq;

            if (Sequence == null)
                return null;

            if (Sequence.HasValue)
            {
                nSeq = (int)Sequence;
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }
        public void Insert(EssMessageSendInfo info)
        {
            try
            {
                dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(EssMessageSendInfo info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(EssMessageSendInfo info)
        {
            try
            {
                dal.Delete(info);
            }
            catch
            {
                throw;
            }
        }

        public void UpdateMessageStatus(EssMessageSendInfo info)
        {
            try
            {
                dal.UpdateMessageStatus(info);
            }
            catch
            {
                throw;
            }
        }
        public string GetNextSendRefNo(string RequestType)
        {
            return dal.GetNextSendRefNo(RequestType);
        }
    }
}
